#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int count(int n)
{
	if (n < 10)
		return 1;
	return 1 + count(n / 10);
}
int sum_all(int n,int num)
{
	if (n >= 10)
		return pow(n%10,num) + sum_all(n / 10, num);
	else
		return pow(n,num);
}
int main()
{
	int n = 0,sum=0,num=0;
	for (n = 0; n < 100000; n++)
	{
		num = count(n);
		sum = sum_all(n,num);
		if(sum==n)
			printf("%d ", n);
	}


	return 0;
}